package dao;

import java.util.ArrayList;
import java.util.List;

import model.SparePart;

public class SparePartDao {
	private List<SparePart> spareParts = new ArrayList<SparePart>();

	private static SparePartDao instance = null;

	public SparePartDao() {

	}

	/**
	 * This is a static method that return new SparePartDao when instance is null
	 * @author Osahon Idehen
	 */
	
	public static SparePartDao getInstance() {
		if (instance == null)
			instance = new SparePartDao();
		return instance;
	}

	/**
	 * This adds a sparePart
	 * @author Osahon Idehen
	 */
	
	public void addSparePart(SparePart sparePart) {
		if (!spareParts.contains(sparePart)) {
			spareParts.add(sparePart);
		}
	}

	/**
	 * This removes a sparePart
	 * @author Osahon Idehen
	 */
	
	public void removeSparePart(SparePart sparePart) {
		if (spareParts.contains(spareParts)) {
			spareParts.remove(sparePart);
		}
	}

	/**
	 * This return spareParts from the list
	 * @author Osahon Idehen
	 */
	
	public List<SparePart> getSpareParts() {
		return spareParts;
	}
}